﻿using MODEL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class ParameterService
    {
            /// <summary>
            /// 查询学生信息
            /// </summary>
            /// <returns></returns>
            public static DataTable ChaXunParameter()
            {
                string sql = "select*from Parameter";

                DataTable dt = SqlHelper.QueryMethod(sql);
                return dt;

            }
            
            /// <summary>
            /// 修改考勤规则
            /// </summary>
            /// <param name="stuCard"></param>
            /// <returns></returns>
            public static int ParameterUpdate(Parameter parameter)
            {
                try
                {
                    string sql = "update Parameter set P_Time1=@P_Time1,P_Time2=@P_Time2  where P_sign=@P_sign ";
                    SqlParameter[] sp =
                  {
                     new SqlParameter("@P_sign",parameter.P_sign),
                     new SqlParameter( "@P_Time1",parameter.P_Time1),
                     new SqlParameter( "@P_Time2",parameter.P_Time2)
                   };

                    int num = SqlHelper.NonQueryMethod(sql, sp);
                    return num;
                }
                catch (Exception ex)
                {

                    throw ex;
                }

            }

        /// <summary>
        /// 删除考勤记录的方法
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static int StuCardDelete(Parameter parameter)
            {
                string sql = "delete from StuCard where P_sign=@P_sign";
                SqlParameter[] sp =
                {
                    new SqlParameter("@P_sign",parameter.P_sign)
                };
                int num = SqlHelper.NonQueryMethod(sql, sp);
                return num;
            }
        }
}
